﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DAL
{
    public class WebSet
    {
        public static void update(WebSetEntity ws)
        {
            DbHelper.ExecuteNonQuery("p_WebSet_update", 
                ws.Id, ws.WebOn, ws.MinAmount, ws.MinTax, ws.RefreshMinute, ws.DeliveryDocCreateHHMM,ws.autoAddPrice,ws.CompanyScore,
                ws.SendSMS,ws.UpdatePriceDt,ws.NotchangePriceDay,ws.DeductRatio,ws.PriceCheckStartTime,ws.PriceCheckEndTime,ws.EnableCheckPrice);
        }
        public static WebSetEntity list()
        {
            WebSetEntity ws = new WebSetEntity();
            DataRow dr = DbHelper.ExecuteDataRow("p_WebSet_list");
            if (dr != null)
            {
                ws.Id = Convert.ToInt32(dr["id"]);
                ws.WebOn = Convert.ToBoolean(dr["webOn"]);
                ws.MinAmount = Convert.ToInt32(dr["minAmount"]);
                ws.MinTax = Convert.ToInt32(dr["minTax"]);
                ws.RefreshMinute = Convert.ToInt16(dr["refreshMinute"]);
                ws.DeliveryDocCreateHHMM = dr["DeliveryDocCreateHHMM"].ToString();
                ws.autoAddPrice = Convert.ToBoolean(dr["autoAddPrice"]);
                if (dr["companyScore"] != DBNull.Value)
                    ws.CompanyScore = Convert.ToInt32(dr["companyScore"]);
                ws.SendSMS = Convert.ToBoolean(dr["sendSMS"]);
                ws.UpdatePriceDt = dr["updatePriceDt"].ToString();
                ws.NotchangePriceDay = Convert.ToInt32(dr["notchangePriceDay"]);
                if (dr["deductRatio"]!=DBNull.Value)
                    ws.DeductRatio = Convert.ToDecimal(dr["deductRatio"]);
                ws.PriceCheckStartTime = dr["priceCheckStartTime"].ToString();
                ws.PriceCheckEndTime = dr["priceCheckEndTime"].ToString();
                if (dr["enableCheckPrice"] != DBNull.Value)
                    ws.EnableCheckPrice = Convert.ToBoolean(dr["enableCheckPrice"]);
            }
            return ws;
        }
    }
}
